//
//  SaleTableViewCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/20.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "SaleTableViewCell.h"

@implementation SaleTableViewCell

#pragma mark - lifecycle methods

- (void)setupUI{
    
    self.backgroundColor = KWhiteColor;
    
    [self.contentView addSubview:self.pigTypeTipLab];
    [self.contentView addSubview:self.pigTypeNOLab];
    [self.contentView addSubview:self.pigTypePriceLab];
    [self.contentView addSubview:self.pigTypeWeightLab];
    [self.contentView addSubview:self.pigTypePriceSignalLab];
    
}

- (void)setupLayout
{
    
    [self.pigTypeTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(13);
        make.top.mas_equalTo(15);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(22);
    }];
    
    [self.pigTypeNOLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.pigTypeTipLab.mas_right).mas_offset(4);
        make.top.mas_equalTo(15);
        make.right.mas_equalTo(-30);
        make.height.mas_equalTo(20);
    }];
    
    [self.pigTypePriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(24);
        make.right.mas_equalTo(-15);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(20);
    }];
    
    
    
    {
        [self.pigTypeWeightLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(13);
            make.top.mas_equalTo(self.pigTypeTipLab.mas_bottom).mas_offset(7);
            make.width.mas_equalTo(66);
            make.height.mas_equalTo(16);
        }];
    }
    
    
    {
        [self.pigTypePriceSignalLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.pigTypeWeightLab.mas_right).mas_offset(5);
            make.top.mas_equalTo(self.pigTypeWeightLab.mas_top);
            make.width.mas_equalTo(89);
            make.height.mas_equalTo(16);
        }];
        
    }
}

#pragma mark - setter methods

- (void)setItem:(ShopSaleDetailItem *)item{
    
    self.pigTypeTipLab.text = @"五花肉";
    self.pigTypeNOLab.text = @"HT-02";
    self.pigTypeWeightLab.text = [NSString stringWithFormat:@"重量%@kg", item.weight];
    self.pigTypePriceSignalLab.text = [NSString stringWithFormat:@"单价%@元/500g", item.unitPrice];
    self.pigTypePriceLab.text = @"¥216";
    
}

#pragma mark - getter methods

- (UILabel *)pigTypeTipLab{
    
    if (! _pigTypeTipLab){
        _pigTypeTipLab = [UILabel makeLabelWithText:@"" textColor:mMainColor font:mFont(12) textAliment:1];
        _pigTypeTipLab.backgroundColor = UIColorFromRGB(0xE9F9F0);
        [self addShadowAndCircleCorner:_pigTypeTipLab.layer corner:3];
    }
    return _pigTypeTipLab;
}


- (UILabel *)pigTypeNOLab{
    
    if (!_pigTypeNOLab){
        _pigTypeNOLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x333333) font:mFont(15) textAliment:0];
    }
    return _pigTypeNOLab;
}


- (UILabel *)pigTypePriceLab{
    
    if (!_pigTypePriceLab){
        _pigTypePriceLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x333333) font:mMediumFont(17) textAliment:2];
    }
    return _pigTypePriceLab;
}


- (UILabel *)pigTypeWeightLab {
    
    if (!_pigTypeWeightLab){
        _pigTypeWeightLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x9C9C9C) font:mFont(10) textAliment:1];
        _pigTypeWeightLab.backgroundColor = UIColorFromRGB(0xF2F4F7);
        [self addShadowAndCircleCorner:_pigTypeWeightLab.layer corner:9];
    }
    return _pigTypeWeightLab;
}


- (UILabel *)pigTypePriceSignalLab{
    
    if (!_pigTypePriceSignalLab){
        _pigTypePriceSignalLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x9C9C9C) font:mFont(10) textAliment:1];
        _pigTypePriceSignalLab.backgroundColor = UIColorFromRGB(0xF2F4F7);
        [self addShadowAndCircleCorner:_pigTypePriceSignalLab.layer corner:9];
    }
    return _pigTypePriceSignalLab;
}




@end
